package com.ms.security.authentication;

import com.ms.security.properties.SecurityConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

/**
 * @author shkstart
 * @create 2020-04-07 15:05
 */
public class AbstractChannelSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private AuthenticationFailureHandler msAuthenticationFailureHandler;

    @Autowired
    private AuthenticationSuccessHandler  msAuthenticationSuccessHandler;

    protected void applyPasswordAuthenticationConfig(HttpSecurity http) throws Exception{

        http.formLogin().loginPage(SecurityConstants.DEFAULT_UNAUTHENTICATION_URL)
                .loginProcessingUrl(SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_FORM)
                .successHandler(msAuthenticationSuccessHandler)
                .failureHandler(msAuthenticationFailureHandler);

    }

}
